<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <ul id="ul">

  </ul>

  <script>
    function getDate() {
      return new Promise((resolve, reject) => {
        let xhr = new XMLHttpRequest()  //创建http请求体实例对象
        xhr.open('GET', 'https://mock.mengxuegu.com/mock/65a91543c4cd67421b34c898/movie/movieList', true)  //朝地址发送请求
        xhr.send()        //后端接收到请求将数据返回回来
        xhr.onreadystatechange = function () {   //接收返回回来的数据
          if (xhr.readyState == 4 && xhr.status == 200) {   //返回的数据解析完毕
            console.log(JSON.parse(xhr.responseText));      //将数据打印成json格式
            resolve(JSON.parse(xhr.responseText).movieList)  //将对象中的一个值作为最终操作的结果resolve出来
          }
        }
      })
    }

    function showList(data) {
      data.forEach(item => {
        let li = document.createElement('li')
        li.innerText = item.nm
        document.getElementById('ul').appendChild(li)
      });
    }

    getDate().then((res) => {
      showList(res)
    })
  </script>
</body>

</html>